package com.shsoft;

import com.shsoft.entity.HardWareInfo;
import com.shsoft.task.*;
import com.shsoft.util.SpringUtil;
import com.shsoft.util.WinRing0Util;
import javafx.application.Application;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import oshi.hardware.GraphicsCard;

import java.util.List;

@EnableAsync
@SpringBootApplication
public class MonitorMain {

    public static void main(String[] args) {
        System.setProperty("java.awt.headless","false");
        SpringApplication.run(MonitorMain.class, args);
        int result = WinRing0Util.InitializeOls();
        ThreadPoolTaskExecutor myAsyncThreadPool = SpringUtil.getBean("myAsyncThreadPool");
        myAsyncThreadPool.execute(new NetTask());
        myAsyncThreadPool.execute(new CpuTask());
        myAsyncThreadPool.execute(new MemTask());
        List<GraphicsCard> graphicsCards = HardWareInfo.systemInfo.getHardware().getGraphicsCards();
        for (GraphicsCard graphicsCard : graphicsCards) {
            if(graphicsCard.getVendor().contains("NVIDIA")){
                myAsyncThreadPool.execute(new GpuTask());
                break;
            }
        }
        Application.launch(MonitorApplication.class, args);
    }

}